import request from '@/utils/request'

// 获取角色列表
export const queryRoles = (data) => {
  return request({
    method: 'post',
    url: '/boss/role/getRolePages',
    data
  })
}

// 获取角色详情
export const getRole = (id) => {
  return request({
    method: 'get',
    url: `/boss/role/${id}`
  })
}

// 保存或更新角色信息
export const saveOrUpdate = (data) => {
  return request({
    method: 'post',
    url: '/boss/role/saveOrUpdate',
    data
  })
}

// 删除指定id角色
export const deleteRole = (id) => {
  return request({
    method: 'delete',
    url: `/boss/role/${id}`
  })
}

// 获取角色拥有的菜单信息
export const getRoleMenus = (roleId) => {
  return request({
    method: 'get',
    url: '/boss/menu/getRoleMenus',
    params: { roleId }
  })
}

// 给角色分配菜单
export const setRoleMenus = (data) => {
  return request({
    method: 'post',
    url: '/boss/menu/allocateRoleMenus',
    data
  })
}

// 获取角色拥有的资源信息
export const getRoleResource = (roleId) => {
  return request({
    method: 'get',
    url: '/boss/resource/getRoleResources',
    params: { roleId }
  })
}

// 获取角色拥有的资源
export const setRoleResource = (data) => {
  return request({
    method: 'post',
    url: '/boss/resource/allocateRoleResources',
    data
  })
}
